package com.welink.cmp.convertor;
import com.welink.cmp.dao.metadata.dataobject.EipDO;
import com.welink.cmp.domain.metadata.Eip;

import java.util.List;
import java.util.stream.Collectors;

/**
 * EIP转换器
 */
public class EipConvertor {

    public static EipDO toDataObject(Eip eip) {
        if (eip == null) {
            return null;
        }
        EipDO eipDO = new EipDO();
        eipDO.setId(eip.getId());
        eipDO.setIp(eip.getIp());
        eipDO.setBandwidth(eip.getBandwidth());
        eipDO.setIsp(eip.getIsp());
        eipDO.setDataCenterCode(eip.getDataCenterCode());
        eipDO.setAccountId(eip.getAccountId());
        eipDO.setChargeType(eip.getChargeType());
        eipDO.setRefId(eip.getRefId());
        eipDO.setRefName(eip.getRefName());
        eipDO.setStatus(eip.getStatus());
        eipDO.setCreateTime(eip.getCreateTime());
        eipDO.setUpdateTime(eip.getUpdateTime());
        eipDO.setCreateBy(eip.getCreateBy());
        eipDO.setUpdateBy(eip.getUpdateBy());
        return eipDO;
    }

    public static Eip toDomainObject(EipDO eipDO) {
        if (eipDO == null) {
            return null;
        }
        Eip eip = new Eip();
        eip.setId(eipDO.getId());
        eip.setIp(eipDO.getIp());
        eip.setBandwidth(eipDO.getBandwidth());
        eip.setIsp(eipDO.getIsp());
        eip.setDataCenterCode(eipDO.getDataCenterCode());
        eip.setAccountId(eipDO.getAccountId());
        eip.setChargeType(eipDO.getChargeType());
        eip.setRefId(eipDO.getRefId());
        eip.setRefName(eipDO.getRefName());
        eip.setStatus(eipDO.getStatus());
        eip.setCreateTime(eipDO.getCreateTime());
        eip.setUpdateTime(eipDO.getUpdateTime());
        eip.setCreateBy(eipDO.getCreateBy());
        eip.setUpdateBy(eipDO.getUpdateBy());
        return eip;
    }

    public static List<EipDO> toDataObjectList(List<Eip> eips) {
        return eips.stream()
                .map(EipConvertor::toDataObject)
                .collect(Collectors.toList());
    }

    public static List<Eip> toDomainObjectList(List<EipDO> eipDOs) {
        return eipDOs.stream()
                .map(EipConvertor::toDomainObject)
                .collect(Collectors.toList());
    }
}